/* 
 * Copyright (c) 2009 Keith Lazuka
 * License: http://www.opensource.org/licenses/mit-license.html
 */

#import "TodaysPlan.h"

@implementation TodaysPlan

@synthesize pkey;
@synthesize date;
@synthesize task;
@synthesize memo;
@synthesize priority;
@synthesize done;
@synthesize reminderDate;
@synthesize reminder;

+ (TodaysPlan*)holidayNamed:(int)apkey date:(NSDate *)aDate task:(NSString *)aTask memo:(NSString *)aMemo priority:(NSString *)aPriority done:(NSString *)aDone reminderDate:(NSString *)areminderDate reminder:(BOOL)areminder;
{
    return [[[TodaysPlan alloc] initWithName:apkey date:aDate task:aTask memo:aMemo priority:aPriority done:aDone reminderDate:areminderDate reminder:areminder] autorelease];
}

- (id)initWithName:(int)apkey date:(NSDate *)aDate task:(NSString *)aTask memo:(NSString *)aMemo priority:(NSString *)aPriority done:(NSString *)aDone reminderDate:(NSString *)areminderDate reminder:(BOOL)areminder;
{
    if ((self = [super init])) {
        pkey = apkey;
        date = [aDate retain];
        task = [aTask copy];
        memo = [aMemo copy];
        priority = [aPriority copy];
        done = [aDone copy];
        reminderDate = [areminderDate copy];
        reminder = areminder;
    }
  return self;
}

- (NSComparisonResult)compare:(TodaysPlan *)otherHoliday
{
  NSComparisonResult comparison = [self.date compare:otherHoliday.date];
  if (comparison == NSOrderedSame)
    return [self.task compare:otherHoliday.task];
  else
    return comparison;
}

- (void)dealloc
{
    [date release];
    [task release];
    [memo release];
    [done release];
    [reminderDate release];
    [super dealloc];
}

@end
